<template>
  <div class="app-container">
      <div class="filter-container">
        
        
        <el-date-picker v-model="search.daterange" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="margin-left:0px;">
        </el-date-picker>
        <el-button type="primary" icon="el-icon-search" @click="searchClick()" style="margin-left:10px;">查询</el-button>
    </div>
    <el-table v-loading="listLoading" :data="list" 
      border fit highlight-current-row stripe 
      style="width: 100%">
      <el-table-column align="center" label="序" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row._id }}</span>
        </template>
      </el-table-column>
     <el-table-column  min-width="100" align="center" label="业务单量">
        <template slot-scope="scope">
          <span>{{ scope.row.buscount }}</span>
        </template>
      </el-table-column>
      <el-table-column  min-width="100" align="center" label="总金额">
        <template slot-scope="scope">
          <span>{{ scope.row.totalmoney }}</span>
        </template>
      </el-table-column>
      
      <el-table-column  min-width="100" align="center" label="制单人">
        <template slot-scope="scope">
          <span>{{ scope.row.guider }}</span>
        </template>
      </el-table-column>
      
      <el-table-column  min-width="100" align="center" label="状态">
        <template slot-scope="scope">
          <span>{{ scope.row.state }}</span>
        </template>
      </el-table-column>
      <el-table-column  min-width="100" align="center" label="日期">
        <template slot-scope="scope">
          <span>{{ scope.row.createtime | parseTime('{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作"  width="420" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="tableRowClick().pay(scope.row.id)">付款</el-button>
          <el-button type="primary" size="small" @click="tableRowClick().details(scope.row.id)">明细</el-button>
          
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.rows" @pagination="getList" />

<!-- 付款 -->
<el-dialog :title="dialogPay.title" :visible.sync="dialogPay.visible"  width="700px">
    <div class="ci">
        <div class="bill" ref="dialogPayBill">
            <div class="item">1、摘要：支付******供应商车款 已支付</div>
            <div class="item">2、科目：</div>
            <div class="item">借1：113200n 预付账款-***单位  金额=23409.00元</div>
            <div class="item">贷1：113300n 中国银行 36月按揭贷款 金额=360000.00元</div>
            <div class="item">贷2：融资支付 210100n 金额=360000.00元</div>
            <div class="item">贷3：厂家返利支付， 1133 单位：**** 金额=360000.00元</div>
        </div>
    </div>
    <div slot="footer" class="dialog-footer">
        <el-button @click="dialogPay.visible = false">取 消</el-button>
        <el-button type="primary" @click="dialogPayClick().print()" :loading="dialogPay.saveloading">保 存</el-button>
    </div>
</el-dialog>
<!-- end 付款 -->


  </div>
</template>

<script>

import { deepClone,parseTime } from '@/utils'
import * as auth from '@/utils/auth'
import * as vehicleApi from '@/api/finance/vehicle'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import Print from '@/utils/print'

var printHandle=null;
export default {
  components: { Pagination },
  data(){
    return{
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        rows: 20,
        number:'',
      },
      selectOptions:{
          billtype:[],
          paytype:[
              {label:'现金',value:'1'},
              {label:'银行',value:'2'},
          ]
      },
      search:{
        number:'',
      },
      dialogPay:{
          visible:false,
          saveloading:false,
          title:'付款',
          data:{

          }
      },
      
    }
  },
  created(){
      var that=this;
      that.searchClick();
  },
  mounted(){

  },
  filters:{
    parseSettleType(val){
       return ['','收益','提现'][val];
    }
  },
  methods: {
    getList(){
      var that=this;
      that.listLoading = true;
      
      vehicleApi.getLicensefeeList(that.listQuery).then(res=>{
         if(res.data && res.data.items){
            that.list=[...res.data.items.map((item,index)=>{
              item._id=index+1;
              return item;
            })];
            that.listLoading = false;
            that.total=res.data.total || 0;
         }
      })
    },
    searchClick(){
      var that=this;
      that.listQuery.page=1;
      that.listQuery.number=that.search.number.trim();
      that.getList();
    },
    tableRowClick(){
        var that=this;
        return {
           pay(id){
               that.dialogPay.visible=true;
           },
           details(id){

           }
        }
    },
    dialogPayClick(){
        var that=this;
        return {
            save(){

            },
            print(){
                if(!printHandle){
                    printHandle=new Print(that.$refs['dialogPayBill']);
                    console.log('init printHandle')
                }
                printHandle.Start();
            }
        }
    },
    
    
  }
}
</script>
<style scoped>

</style>
